<template>
    <view class="savepadding">
        <u-search shape="square"
                  border="none"
                  v-model="formData.keywords"
                  bgColor="#fff"
                  placeholder="请输入客户名称/联系人/手机号/业务员"
                  placeholderColor="#CDCDCD"
                  :showAction="false"
                  @search="onsearch"></u-search>
        <view class="select-wrap" v-if="false">
            <view class="select"
                  @click="onselect(1)">
                <text>{{conditionkey1}}</text>
                <u-icon name="arrow-down"></u-icon>
            </view>
        </view>
        <view>
            <template v-for="item in list">
                <Cardkehu :key="item.id"
                          :item="item"
                          @select="onselectkehu"></Cardkehu>
            </template>
            <u-empty mode="list"
                     marginTop="200"
                     v-if="!list.length"></u-empty>
        </view>
        <u-picker :show="showcondition1"
                  :columns="conditionlist1"
                  keyName="label"
                  @cancel="cancel1"
                  @confirm="onconfirm1"></u-picker>
    </view>
</template>

<script>
import Cardkehu from '@/components/mmv-ui/card-kehu.vue'
import * as customApi from '@/api/custom-api'

export default {
    components: {
        Cardkehu,
    },
    data() {
        return {
            showcondition1: false,
            conditionkey1: '全部',
            conditionvalue1: {},
            conditionlist1: [[
                { label: '全部', id: 0 },
                { label: '我负责的', id: 0 },
                { label: '本人及下属', id: 0 },
                { label: '本部门', id: 0 },
            ]],
            list: [
                // {
                //     "customerId": '3', // "客户id",
                //     "customerType": '1', // "客户类型；1企业2个人",
                //     "customerName": '孙洋洋', // "客户名称",
                //     "contactPerson": '米米法', // "联系人",
                //     "contactMobile": '13344445555', // "联系电话",
                //     "idCardImg": '', // "身份证正面",
                //     "idCardImgBack": '', // "身份证背面",
                //     "idCardExpirydate": '', // "身份证失效日期",
                //     "idCardNo": '0123456789012345678', // "身份证号",
                //     "licenseImg": '', // "营业执照图片",
                //     "license": '', // "营业执照号码",
                //     "businessPersonId": '', // "业务员id",
                //     "businessPersonName": '', // "业务员名称",
                //     "signOrderCount": '10', // "签约订单数量",
                //     "bankCount": '', // "绑定银行卡数量",
                //     "cardImgFront": '', // "银行卡正面",
                //     "cardImgBack": '', // "银行卡背面",
                //     "mobileNo": '18700927778', // "银行卡签约手机号",
                //     "bankCardNo": '6217004220012176644', // "银行卡号",
                //     "bankDeposit": '中国天地银行', // "开户行",
                //     "bankCardType": '0', // "0:储蓄卡  1.信用卡",
                //     "expireDate": '', // "信用卡时效日期",
                //     "cvv": '', // "信用卡安全吗"
                // },
            ],
            formData: {
                page: 1,
                pageSize: 10,
                keywords: '',
            },
        };
    },
    async mounted() {
        this.getlist();
    },
    methods: {
        async getlist() {
            try {
                const result = await customApi.customlist(this.formData);
                console.log(result)
                this.list = result.data;
            } catch (error) {
                uni.showToast({ title: error, icon: 'error' });
            }
        },
        onsearch() { },
        onselect(index) {
            this[`showcondition${index}`] = true;
        },
        onconfirm1({ value }) {
            this.showcondition1 = false;
            this.conditionkey1 = value[0].label;
            this.conditionvalue1 = value[0];
        },
        cancel1() {
            this.showcondition1 = false;
            this.conditionkey1 = '全部';
            this.conditionvalue1 = {};
        },
        onselectkehu(item) {
            uni.navigateTo({
                url: `/pagesA/qianyue/index?kehu=${JSON.stringify(item)}`
            })
        },
    },
}
</script>

<style lang="scss" scoped src="@/styles/mmv.scss"></style>